#include "cgal_source_point.h"
#include <vtkCellArray.h>
#include <vtkPolyData.h>

namespace cgalView {
vtkTypeBool
cgal_source_point::RequestData(vtkInformation *request,
                               vtkInformationVector **inInfoVector,
                               vtkInformationVector *outInfoVector) {
  if (!d_mesh) {
    return false;
  }

  if (d_mesh->number_of_vertices()) {
    return false;
  }

  auto points = vtkPoints::New();
  for (auto const &p : d_mesh->points()) {
    points->InsertNextPoint(p.x(), p.y(), p.z());
  }
  vtkPolyData::GetData(outInfoVector)->SetPoints(points);

  return true;
}
} // namespace cgalView